package com.wonders.hisdoctor.station.project.record.controller;

import cn.hutool.http.server.HttpServerRequest;
import com.wonders.his.common.bean.BaseResult;
import com.wonders.his.framework.dto.LoginUserDTO;
import com.wonders.hisdoctor.station.project.hisqueue.vo.ClinicMasterQueryVo;
import com.wonders.hisdoctor.station.project.medicine.vo.QryClinicVO;
import com.wonders.hisdoctor.station.project.record.service.IRecordService;
import com.wonders.hisdoctor.station.project.record.vo.OutpMrPrintVo;
import com.wonders.hisdoctor.station.project.record.vo.OutpMrVo;
import com.wonders.hisdoctor.station.project.record.vo.OutpRequestVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.Date;
import java.util.List;

/**
 * Description: 门诊病例
 *
 * @author tong-aj
 * <p>
 * Create: 2021-01-18 17:36
 */
@RestController
@RequestMapping("/record")
public class RecordController {

    private final IRecordService recordService;

    public RecordController(IRecordService recordService) {
        this.recordService = recordService;
    }

    @ApiOperation("查看病历")
    @PostMapping("/queryRecord")
    public BaseResult<OutpMrVo> queryRecord(@Valid @RequestBody OutpRequestVo requestVo) {
        return recordService.queryRecord(requestVo);
    }

    @ApiOperation("就诊记录，病历查询")
    @PostMapping("/queryRecordHistory")
    public BaseResult<OutpMrVo> queryRecordHistory(@Valid @RequestBody OutpRequestVo requestVo) {
        return recordService.queryRecordHistory(requestVo);
    }



    @ApiOperation("保存病历")
    @PostMapping("/saveRecord")
    public BaseResult<String> saveRecord(@Valid @RequestBody OutpMrVo outpMrVo, HttpServletRequest request) {
        return recordService.saveRecord(outpMrVo,request);

    }

    @ApiOperation("是否有诊断")
    @PostMapping("/checkDiagnose")
    public BaseResult<String> checkDiagnose(@Valid @RequestBody OutpRequestVo requestVo){
        return recordService.checkDiagnose(requestVo);
    }

    @ApiOperation("病历打印")
    @GetMapping("/print")
    public BaseResult<OutpMrPrintVo> print(String patientId, @DateTimeFormat(pattern = "yyyy-MM-dd") Date visitDate, String visitNo,HttpServletRequest request){
        return BaseResult.success(recordService.print(patientId,visitDate,visitNo,request));
    }


    @ApiOperation("查询病历历史记录")
    @PostMapping("/selectMrList")
    public BaseResult<List<ClinicMasterQueryVo>> selectMrList(@RequestBody QryClinicVO qryClinicVO) {
        return BaseResult.success(recordService.selectMrList(qryClinicVO));
    }
}
